<a id="top" name="top"></a>
<?php
if (!function_exists('welcome_msg')) {
    function welcome_msg() {
        //test 最多十四个汉字
        //return '一二三四五六七八九十一二三四';

        $msg[] = '欢迎回来!';

        if(!$_SESSION['welcome_msg'] || $_GET['update']) $_SESSION['welcome_msg'] = '，'.$msg[rand(0,count($msg)-1)];
        return $_SESSION['welcome_msg'];
    }
}

$urlfrom = urlencode(preg_replace('/from=[^&]+/', '', $_SERVER['REQUEST_URI']));
//fix openid logout bug
if (strpos($urlfrom, 'openid')) $urlfrom = '/openid';
?>

<div id="topbar">
    <div id="topbar_logo"><a tabindex="100" href="<?php echo $_servername?>" title="返回<?=SITE_NAME?>首页"><span>&nbsp;</span></a></div>
    <div id="topbar_nav">
        <ul>
            <?php if ($session['login']):?>
                <li><b><?php echo $session['nickname']?></b>
                <?php echo welcome_msg();?>
                <?php if($session['admin']):?> <b>(<a href="<?php echo $_servername?>/admin/" title="后台管理">A</a>)</b><?php endif?>
                <?php if(strlen($session['username'])==32):?> (<b><a href="/openid" title="管理您的 OpenID">OpenID</a></b>)<?php endif?>
                </li>
                <li><a rel="nofollow" tabindex="20" href="<?php echo $_servername?>/my/">我的乐铺</a></li>
                <li><a rel="nofollow" tabindex="20" href="<?php echo $_servername?>/login.php?logout=1&amp;from=<?php echo $urlfrom?>">退出</a></li>
            <?php else:?>
                <li><a href="<?php echo $_servername?>/">乐铺首页</a></li>
                <li><a rel="nofollow" id="ll" tabindex="20" href="<?php echo $_servername?>/login?from=<?php echo $urlfrom?>">登录</a><a style="display:none" id="_ll" href="<?php echo $_servername?>/login.php?iframe&amp;from=<?php echo $urlfrom?>" rel="ajax" class="lightview" title=":: :: autosize:true,topclose:true,menubar:false"></a></li>
                <li><a tabindex="20" href="<?php echo $_servername?>/imnew?from=<?php echo $urlfrom?>">注册</a></li>
            <?php endif?>
            
            <li><a tabindex="20" href="<?php echo $_servername?>/cats">商品分类</a></li>
            <li><a tabindex="20" href="<?php echo $_servername?>/flow">购物流程</a></li>
            <li><a tabindex="20" href="<?php echo $_servername?>/comments/all">用户评论</a></li>
            <li><a tabindex="20" href="<?php echo $_servername?>/forum/1">客服论坛</a></li>
            <li style="border:0"><a tabindex="20" href="<?php echo $_servername?>/faq">帮助</a></li>
        </ul>
    </div>
    <br clear="all" /><?php echo round_table('100%', 'EEEEEE', 'white', 5, 5, 'bottom')?>
</div>
